package com.yc.controller.xcx;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yc.controller.weixin.GenericController;
import com.yc.service.xcx.user.IXCXUserService;
import com.yc.util.PageData;
import com.yc.util.ReturnModel;


@Controller
@RequestMapping("/app/user")
public class EUserController extends GenericController {
	
	
	@Resource
	private IXCXUserService xCXUserService;
	

	/**
	 * 添加用户基本信息
	 * @param response
	 * @throws Exception 
	 */
	@RequestMapping(value = "/addUserInfor")
    public void addUserInfor(HttpServletResponse response)  {
        	
			PageData pd = new PageData();
			pd = this.getPageData();
			
			ReturnModel returnModel = new ReturnModel();
			returnModel.setResult(true);
        	returnModel.setReason(null);
        	returnModel.setDatum(null);
        	
			try {
				xCXUserService.saveUserInfor(pd);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				returnModel.setResult(false);
	        	returnModel.setReason(e.getMessage());
	        	returnModel.setDatum(null);
			}

            renderString(response, returnModel);
    }
	
	@RequestMapping(value = "/getUserInfor")
	public void getUserInfor(HttpServletResponse response){
		
		PageData pd = new PageData();
		pd = this.getPageData();
		
		ReturnModel returnModel = new ReturnModel();
		
		try {
			
			PageData item = xCXUserService.getUserInfor(pd);
			
			if(item!=null){
				returnModel.setResult(true);
	        	returnModel.setReason(null);
	        	returnModel.setDatum(item);
			} else {
				returnModel.setResult(false);
	        	returnModel.setReason("用户不存在！");
	        	returnModel.setDatum(null);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			returnModel.setResult(false);
        	returnModel.setReason(e.getMessage());
        	returnModel.setDatum(null);
		}

        renderString(response, returnModel);
		
	}
	

}
